package com.zh.auth.service.impl;

import com.zh.auth.mapper.PermissionMapper;
import com.zh.auth.mapper.RoleMapper;
import com.zh.auth.mapper.RolePermissionMapper;
import com.zh.auth.mapper.UserRoleMapper;
import com.zh.auth.service.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
@RequiredArgsConstructor
/**
 * 仅系统调用
 */
public class CallBySystemServiceImpl implements CallBySystemService {

    private final UserRoleMapper userRoleMapper;
    private final RoleMapper roleMapper;
    private final PermissionMapper permissionMapper;
    private final RolePermissionMapper rolePermissionMapper;

    /**
     * 系统调用 删除过期数据
     *
     * @return Boolean
     */
    @Override
    public String clearAllExpireData() {
        try {
            userRoleMapper.permanentlyDelete();
            roleMapper.permanentlyDelete();
            permissionMapper.permanentlyDelete();
            rolePermissionMapper.permanentlyDelete();
            return "清除成功";
        } catch (Exception e) {
            log.error("清除ls_user过期数据失败", e);
            return "清除失败";
        }

    }
}
